package com.iwhalecloud.citybrain.flow.platform.manager.common.client;

import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @author lilh
 * @date 2019-02-18 16:12
 */
@Data
public class HttpCreateProcessInstanceDto extends HttpCommandDto {
    private static final long serialVersionUID = 3386528773864784542L;

    private String flowPackageCode;

    private String priority;

    private Map<String, Object> flowParamList;

    private Map<String, Object> flowPassList;

    private String ordId;

    private String participantId;

    private String participantName;

    private String participantType;

    private List<TaskReadDoDto> taskReadDoDtoList;

    /**
     * 对象实例ID
     */
    private String objectInstanceId;

    public HttpCreateProcessInstanceDto() {
        this.setCommandCode("createProcessInstance");
    }

    @Override
    public Map<String, Object> toMap() {
        Map<String, Object> map = super.toMap();
        map.put("FLOWPACKAGECODE", this.flowPackageCode);
        map.put("PRIORITY", this.priority);
        map.put("FLOW_PARAM_LIST", this.flowParamList);
        map.put("FLOW_PASS_LIST", this.flowPassList);
        map.put("ORD_ID", this.ordId);
        map.put("PARTICIPANTID", this.participantId);
        map.put("PARTICIPANTNAME", this.participantName);
        map.put("PARTICIPANTTYPE", this.participantType);
        map.put("OBJECTINSTANCEID", this.objectInstanceId);
        return map;
    }

    @SuppressWarnings("unchecked")
    @Override
    public void init(Map<String, Object> paramsMap) {
        super.init(paramsMap);
        this.flowPackageCode = String.valueOf(paramsMap.get("FLOWPACKAGECODE"));
        this.priority = String.valueOf(paramsMap.get("PRIORITY"));
        if (paramsMap.get(FLOW_PARAM_LIST_STR) != null) {
            this.flowParamList = (Map) paramsMap.get("FLOW_PARAM_LIST");
        }

        if (paramsMap.get(FLOW_PASS_LIST_STR) != null) {
            this.flowPassList = (Map) paramsMap.get("FLOW_PASS_LIST");
        }

        this.ordId = String.valueOf(paramsMap.get("ORD_ID"));
        this.participantId = String.valueOf(paramsMap.get("PARTICIPANTID"));
        this.participantName = String.valueOf(paramsMap.get("PARTICIPANTNAME"));
        this.participantType = String.valueOf(paramsMap.get("PARTICIPANTTYPE"));
        this.objectInstanceId = String.valueOf(paramsMap.get("OBJECTINSTANCEID"));
    }

}
